<template>
	<view> 
		<!-- 客户信息 -->
		<view class="manage_con">
			<view class="clineInfo" v-for="(item,index) in list" :key="index">
				<view class="info_head">
					<view>{{item.memberName}} </view>
				</view>
				<view class="info_main">
					<view @click="toMore(item.id,1)">
						<view class="main_left"> 
							<view class="left_top" style="margin: 30rpx 0;color: #666;font-size: 30rpx;">
								生日:{{item.birthday? item.birthday : ''}}
							</view>
						</view>
					</view>
					<view class="main_right">
						<image :src="BASE_IMG_URL+'headImg.png'"  mode="scaleToFill">
						</image>
						<view>{{item.operatorName||''}} {{item.advisorName||''}}</view>
					</view>
				</view>
				<view class="info_footer">
					<view class="footer_content" @click="followClick(item.id,1)">
						<image :src="BASE_IMG_URL+'tj.png'"  mode="scaleToFill"></image>
						<view>跟进</view>
					</view> 
					<view class="footer_content" @click="telClick(item)">
						<image :src="BASE_IMG_URL+'dh.png'"  mode="scaleToFill"></image>
						<view>电话</view>
					</view>
				</view>
			</view>
			<view style="height: 200rpx;"></view>
			<u-empty v-if="list.length == 0" text="暂无更多"></u-empty>
		</view>
		<u-action-sheet
			:list="taskActions" 
			v-model="taskShow"
			:cancel-btn = "true"
			@cancel.natice="onCancel"
		></u-action-sheet>
		<u-action-sheet
			:list="telActions" 
			v-model="telShow"
			:cancel-btn = "true"
			@cancel.natice="onCancel"
			@select="selectPhone"
		></u-action-sheet> 
		
	</view>
</template>

<script>
	import uniTabbar from '@/components/tabbar/tabbar.vue'
	import selectTemp from '@/components/content/selectTemp/selectTemp.vue';
	import {
		customerSortDatas
	} from 'components/content/data/data.js';
	import { BASE_IMG_URL } from '@/util/api.js'
	import {
		customerPageJumps
	} from "../crm_page_jumps.js";
	import {
		netGetRecentBirthdayList
	} from '@/api/kehu.js'
	import {
		netAgentList
	} from '@/api/clues.js'
	export default {
		mixins: [customerPageJumps],
		data() {
			return {
				BASE_IMG_URL:BASE_IMG_URL,
				sort: false,
				screen: false,
				date: '',
				show: false,
				sortData: customerSortDatas,
				screenData: [],
				taskShow: false,
				telShow: false,
				description: '',
				taskActions: [{
						name: '普通任务',
						color: '#03aa96'
					},
					{
						name: '跟进任务',
						color: '#03aa96'
					}
				],
				telActions: [],
				queryObj: {},
				page: 1,
				totalPage: 1,
				limit: 10,
				list: [],
				//默认 筛选条件
				de_type: 100,
				de_starttime: '',
				de_endtime: '',
				de_staffid: null,
				tipNumber: null,
				isAdd:true,
			}
		},
		components: {
			selectTemp,
			uniTabbar
		},
		onLoad(options) {
			if (options.type) {
				this.de_type = options.type
				this.de_starttime = options.startTime
				this.de_endtime = options.endTime
				this.de_staffid = options.staffid
			}
		},
		onShow() {
			this.getTip()
		},
		onReachBottom() {
			if (this.page >= this.totalPage) {
				return
			}
			this.page++
			this.getList()
		},
		methods: {
			getTip() {
				netAgentList().then(res => { 
					this.tipNumber = 0

					this.list = []
					this.page = 1
					this.totalPage = 1
					//获取客户 列表
					this.getList()
				})
			},
			queryData(params) {
				console.log(params)
				this.queryObj = params
				this.list = []
				this.page = 1
				this.getList()
			},
			getList() {
				let params = {
					page: this.page,
					limit: this.limit,
					createtime: (this.de_starttime && this.de_endtime) ? (this.de_starttime + ',' + this.de_endtime) :
						'',
					type: this.de_type == 0 ? 1 : this.de_type == 1 ? 0 : null,
					staff_id: this.de_staffid,
					...this.queryObj
				}
				netGetRecentBirthdayList(params).then(res => {
					res = res.data
					this.list = this.list.concat(res.list)
					console.log(this.list,'=====')
					this.page = res.page
					this.totalPage = res.totalPage
				})
			},
			sortClick(data) {
				this.sort = data;
				this.screen = false;
			},
			screenClick(data) {
				this.screen = data;
				this.sort = false;
			},
			switchover(value) {
				this.screenData = value;

			},
			// 任务
			taskClick() {
				this.taskShow = true;
			},
			// 电话
			telClick(item) {
				if (item) {
					uni.showModal({
						title:item.memberName,
						content:'手机号码:' + item.mobile,
						success:(res)=>{
							if(res.confirm){
								// #ifdef MP-ALIPAY
								dd.showCallMenu({
								    phoneNumber: item.mobile, 
								    code: '+86'
								})
								// #endif
								// #ifdef MP-WEIXIN || H5 || APP-PLUS
								uni.makePhoneCall({
									phoneNumber: item.mobile
								})
								// #endif
							}
						}
					})
				} else {
					uni.showToast({
						title: '暂无联系方式',
						icon: 'none'
					})
					this.telActions = []
					this.description = ''
				}
			},
			selectPhone(e) {
				console.log(e)
				uni.makePhoneCall({
					phoneNumber: e.detail.phone
				})
			},
			onCancel() {
				this.taskShow = false;
				this.telShow = false;
			},
		}
	}
</script>

<style lang="scss">
	.clineInfo {
		background-color: #fff;
		padding: 30rpx 45rpx;
		margin-bottom: 20rpx;
		border-radius: 10rpx;
		box-shadow: 2rpx 2rpx 50rpx rgba(0, 0, 0, 0.1);

		.info_head {
			display: flex;
			justify-content: space-between;

			:first-child {
				font-size: 34rpx;
				font-weight: 700;
				color: #333;
			}
		}

		.info_main {
			display: flex;
			justify-content: space-between;

			.main_left {
				.left_followUp {
					display: flex;
					padding-bottom: 30rpx;
					font-size: 30rpx;
					color: #666;
				}

				.left_star {
					font-size: 30rpx;
					color: #666;
					display: flex;
					padding-bottom: 30rpx;
				}

				.left_foot {
					padding-bottom: 20rpx;

					.l_box {
						margin-right: 35rpx;
						float: left;

						span {
							background: rgba(3, 170, 150, .1);
							padding: 5rpx 12rpx;
							font-size: 26rpx;
							color: #03AA96;
							border-radius: 5rpx;
						}
					}
				}
			}

			.main_right {
				text-align: center;
				padding: 20rpx 15rpx 0 0;

				image {
					border-radius: 50%;
					width: 129rpx;
					height: 129rpx;
					margin-bottom: 5rpx;
				}
			}
		}

		.info_footer {
			display: flex;
			justify-content: space-around;
			padding-top: 30rpx;
			height: 80rpx;
			border-top: 1px solid #ededed;
			margin-top: 20rpx;

			.footer_content {
				// width: 25%;
				line-height: 28rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				image{
					width: 48rpx;
					height: 48rpx;
					margin-right: 15rpx;
				}
				.icon-iconmore-copy,
				.icon-follow {
					font-size: 22rpx;
				}

				.icon-follow,
				.icon-task,
				.icon-tel {
					margin-right: 5rpx;
				}

				.icon-iconmore-copy {
					margin-left: 5rpx;
					margin-top: 2rpx;
				}
			}
		}
	}

	.icon_creat {
		position: fixed;
		z-index: 1;
		bottom: 180rpx;
		right: 80rpx;

		image {
			width: 80rpx;
			height: 80rpx;
			border-radius: 50%;
		}
	}
</style>
